<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>正则表达式</title>
</head>
<body>
    <h1>正则表达式</h1>
    <p>正则表达式描述字符的模式对象</p>
    <p>语法：
        var patt= new RegExp(pattern,modifies)
        或者
        var patt =/pattern/modifies
        pattern:表示正则表达式
        modofies：表示模式，分为全局模式g，区分大小写i 
        i 执行不区分大小写匹配  取一个
        g：执行全文检索 一模一样 有几个取几个
    </p>
    <script>
        var str='is this all there is!';
        var patt =/is/g
        var f = str.match(patt);
    
        console.log(f);
        patt = newRegExp('Is',i);
    //正则表达式是否匹配
        var f = patt.test(str);//true
        console.log(f);
    //判断匹配内容
        f= patt.exec(str);
        console.log(f);//is


       // 'abc123bcd456hig789'将数字换成#number字符串
  var str= 'abc123bcd456hig789';
  var patt= str.replace(/[0-9]+/g,"#number");
  console.log(patt);
  //,,,123,,,45,,66,,78,,,,拆分获得数字
  var str= ",,,123,,,45,,66,,78,,,,";
  var strs=str.split('\,');
  for(var i=0;i<=str.length;i++){
    console.log(strs[i]);
  }
    </script>
</body>
</html>